package utils;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtils {
	
	private static final Configuration CONFIGURATION;
	private static final SessionFactory SESSION_FACTORY;
	
	static {
		CONFIGURATION = new Configuration().configure();
		SESSION_FACTORY = CONFIGURATION.buildSessionFactory();
	}
	
	// 获取当前线程绑定的会话
	public static Session getCurrentSession(){
		return SESSION_FACTORY.getCurrentSession();
	}
	
}
